package cn.hsa.xxx.salesMonitor.controller;


import cn.hsa.hsaf.core.framework.web.WrapperResponse;
import cn.hsa.xxx.api.service.BookSalesMonitorService;
import io.swagger.annotations.Api;
import javafx.util.Pair;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@RequestMapping("/web/salesMonitor")
@RestController
@Slf4j
@Api(tags = "销售监控")
public class bookSalesMonitorController {

    @Resource(name = "bookSalesMonitor")
    BookSalesMonitorService bookSalesMonitorService;

    @GetMapping("/salesVolumeRank")
    public WrapperResponse<List<Pair<String, Integer>>> salesVolumeRank(@RequestParam Date beginDate,@RequestParam Date endDate) {
        List<Pair<String, Integer>> salesVolumeRank = bookSalesMonitorService.getSalesVolumeRank(beginDate, endDate);
        return WrapperResponse.success(salesVolumeRank);

    }

    @GetMapping("/salesPriceRank")
    public WrapperResponse<List<Pair<String, Float>>> salesPriceRank(@RequestParam Date beginDate, @RequestParam Date endDate) {
        List<Pair<String, Float>> salesVolumeRank = bookSalesMonitorService.getSalesPriceRank(beginDate, endDate);
        return WrapperResponse.success(salesVolumeRank);

    }
}
